package com.zipking.cloud.springbootmybatis.util;

import cn.hutool.db.PageResult;
import org.apache.poi.ss.formula.functions.T;

import java.util.List;

public class PageStaticUtils {

    /**
     * 后端计算分页
     *
     * @param list list
     * @param page page
     * @return PageResult
     */
    /*public PageResult<T> pageData(List<T> list, Pageable page) {
        int total = list.size();
        int pages = (total / page.getPageSize()) + (total % page.getPageSize() > 0 ? 1 : 0);
        int start = page.getPageSize() * page.getPageNumber();
        int end = Math.min((start + page.getPageSize()), total);
        PageResult<T> pageResult = new PageResult<T>();
        pageResult.setNowPage(page.getPageNumber() + 1);
        pageResult.setPages(pages);
        pageResult.setPageSize(page.getPageSize());
        pageResult.setTotal(total);
        pageResult.setList(list.subList(start, end));
        return pageResult;
    }

    *//**
     * 获取序号
     *
     * @param list
     * @param data
     * @param pageSize
     * @param nowPage
     * @return
     *//*
    public Integer getPageNum(List<T> list, T data, Integer pageSize, Integer nowPage) {
        return (list.indexOf(data) + 1) + pageSize * nowPage;
    }*/

}
